package com.station;

/**
 * @author SnowmanAndBee
 * @version <version>
 * <description>
 * @date 2021/12/14 - 20:21
 */
public class ForecastDisplay implements Observer, DisplayElement{
    private double temperature;
    private double humidity;
    private double pressure;
    private Subject weatherData;

    public ForecastDisplay(Subject weatherData) {
        this.weatherData = weatherData;
        weatherData.registerObserver(this);
    }

    @Override
    public void display() {
        if (temperature > 80) {
            System.out.println("Improving weather on the way!");
        } else {
            System.out.println("Watch out for cooler, rainy weather");
        }
    }

    @Override
    public void update(double temp, double humidity, double pressure) {
        this.temperature = temp;
        this.humidity = humidity;
        this.pressure = pressure;
        display();
    }
}
